package cn.tedu.imop.marketing.controller;

import cn.tedu.imop.api.model.RestResult;
import cn.tedu.imop.api.model.RestResultUtils;
import cn.tedu.imop.common.constants.Constants;
import cn.tedu.imop.common.pojo.PageData;
import cn.tedu.imop.marketing.entity.Activity;
import cn.tedu.imop.marketing.service.ActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags="活动管理")
@RestController
@RequestMapping(Constants.CONTROLLER_API_VERSION+"/activity")
public class ActivityController {
    private ActivityService activityService;

    public ActivityController(ActivityService activityService) {
        this.activityService = activityService;
    }
    @ApiOperation("添加活动")
    @PostMapping
    public RestResult<Void> createActivity(Activity activity){
        activityService.createActivity(activity);
        return RestResultUtils.success();
    }
    @ApiOperation("活动列表")
    @GetMapping
    public RestResult<PageData<Activity>> getActivityList(Activity activity){
        return RestResultUtils.success(activityService.getActivityList(activity));
    }
}
